/**
 * Created by chenke on 2017/5/16.
 */
$(function(){
    //    注册
    /*$(".reg-btn-ck").click(function() {
     event.stopPropagation();
     event.defaultPrevented;
     return false;
     });*/
    $(".reg-btn-ck").click(function() {
//                event.stopPropagation();
//                event.defaultPrevented();
        console.log(11231231);
        var name = $(".username").val(),
            pass = $(".userpass").val(),
            pass2 = $(".userpass2").val();
//                console.log(name);
//                console.log(pass);
//                console.log(pass2);
//                return false;
////        查询user是否存在
        $.ajax({
            type:"post",
            url:"/postseachuser_PC",
            data:{
                text1:name
            },
            success:function(data){
                console.log(data);
                if(data==""||data==null||data==undefined){
                    adddata(name,pass);
                }else{
                    //alert("该用户已存在")
                    $('.tipdiv').append(
                        '<div class="alert alert-danger alert-dismissible fade in" role="alert" ' +
                        ' style="  margin-top: 10px; margin-right: -20px;margin-left: 20px;"> ' +
                        '<button type="button" class="close" data-dismiss="alert" aria-label="Close">' +
                        '<span aria-hidden="true">×</span></button>' +
                        '注册提示:账号已存在。</div>'
                    );
                }
            }
        });
//        添加用户
        function adddata(data1,data2){
            $.ajax({
                type:"post",
                url:"/postadduser_PC",
                data:{text1:data1,text2:data2},
                success:function(data){
                    window.location.href = 'login.html';
                }
            });
        }

    });
});
